'use strict';
const SQL = require("./mysql");


var mySQL = new SQL();

var result = [];

main()
function main() {
    mySQL.clearAllSelected();
}


// =========== 函数区 ===============
function insertData() {
    const sql = "INSERT INTO `wzm`(`ques`,`clef`,`keySignature`) VALUES ('李四','aaa','男'),('王五','aaaaaa','男')";
    mySQL.exec({
        sql,
        callback: function (result) {
            console.log(result);
        }
    });
}


function showData() {
    // const sql = 'select * from wzm'; // 查询所有
    // const sql = 'select * from wzm where id = 13';
    // const sql = 'select * from wzm where isToday = 1 and  order by rand() Limit 3';
    const sql = 'select * from wzm where isToday = 1 and isSelected = 0 and count < 4 order by rand() Limit 20'
    mySQL.exec({
        sql,
        callback: function (result) {
            console.log(result);
        }
    });
}

function clearData() {
    // const sql = 'UPDATE wzm SET isSelected = 0'; // 清空所有已选
    const sql = 'UPDATE wzm SET isToday = 1'; // 清空当日选项

    mySQL.exec({
        sql,
        callback: function (result) {
            console.log(result);
        }
    });
}

function clearAllToday() {
    const sql = 'UPDATE wzm SET isToday = 1'; // 清空当日选项
    mySQL.exec({
        sql,
        callback: function (result) {
            console.log(result);
        }
    });
}

